<div class="row">
    <div class="col-lg-12">
        <h1 class="page-header">Quản lý kênh</h1>
        <a href="<?php echo $baseurl.'manage/content/add-channel'?>" class="btn btn-success btn-lg add">Thêm kênh</a>
    </div>
    <!-- /.col-lg-12 -->

    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                &nbsp;Danh sách các kênh
            </div>
            <!-- /.panel-heading -->
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th>STT</th>
                                <th>Tên kênh</th>
                                <th style="text-align: center">Logo kênh</th>
                                <th style="text-align: center">&nbsp;</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $i = 0; foreach($data AS $key=>$value): $i=$i+1;?>
                                <tr>
                                    <td><?php echo $i?></td>
                                    <td><?php echo $value->name?></td>
                                    <td style="text-align: center"><img style="width: 100px;height: 100px" alt="<?php echo $value->name?>" src="<?php echo $imgurl.$value->logo?>" onerror="this.src='<?php echo $baseurl;?>public/images/no-image.png';"/></td>
                                    <td style="text-align: center">
                                        <a href="<?php echo $baseurl.'manage/content/edit-channel/'.$value->id?>"><i class="fa fa-edit"></i></a>
                                        <a data-id="<?php echo $value->id?>" class="deleterow"><i class="fa fa-trash-o"></i></a>
                                    </td>
                                </tr>
                            <?php endforeach;?>
                        </tbody>
                    </table>
                </div>
                <!-- /.table-responsive -->
            </div>
            <!-- /.panel-body -->
        </div>
        <!-- /table -->
    </div>
    <!-- /.col-lg-12 -->
</div>

<script>
$(document).ready(function() {
    $('#dataTables-example').dataTable();
});

$('.deleterow').click(function(){
    var id = $(this).data('id');
	var conf = confirm('Bạn muốn xóa chương trình này?');
	if(conf)
		$(this).parents('tr').fadeOut(function(){
			$(this).remove();
			$.ajax({
                type: "GET",
			    url: baseUrl+'manage/content/delete-channel',
                data: ({id : id})
			});
		});
	return false;
});
</script>